package jdbc;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

public class RegDemo {
    public static void main(String[] args) {
        try (Connection getconnection = DBUtil.getConnection();){
            System.out.println("请输入用户名");
            Scanner scanner = new Scanner(System.in);
            String username = scanner.next();
            System.out.println("请输入密码");
          String password = scanner.next();
            System.out.println("请输入昵称");
           String nickname = scanner.next();
            System.out.println("请输入年龄");
            int age = scanner.nextInt();

            Statement statement = getconnection.createStatement();

            statement.executeUpdate("INSERT INTO user(username,password,nickname,age) " +
                    "VALUES('" + username + "','" + password + "','" + nickname + "'," + age + ")");


        } catch (SQLException e) {
            throw new RuntimeException(e);
        }

    }
}
